package WhileDemo1;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class InfiniteLoopExample {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd号 HH:mm:ss");

        while (true) {
            System.out.print("请输入数据（按n退出循环）: ");
            String input = scanner.nextLine();

            if ("n".equalsIgnoreCase(input)) {
                break;
            }


            String currentTime = sdf.format(new Date());
            System.out.println(currentTime + "：循环操作中~~~ 按n退出循环");
        }

        System.out.println("循环已退出。");
        scanner.close();
    }
}
